﻿Imports System.Data.OleDb
Imports System.DBNull
Imports System.Data.SqlClient
Public Class giahanthe
    Public db As New Class1
    Dim gt As Boolean
    Public sql As String
    Public mycom As OleDbCommand
    Dim con As OleDbConnection
    Private Sub giahanthe_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        db.connectDB()
        showDataGrid()
        sql = "select * from BanDoc"
        db.strSQL(sql)
        While db.myda.Read()
            cbmabandoc.Items.Add(db.myda.GetString(0))
        End While
    End Sub

    Sub showDataGrid()
        sql = "Select MaBD as 'Mã Bạn Đọc', Ngaylapthe as'Ngày Lập Thẻ ', Ngayhethan as 'Gia Hạn Tới' From BanDoc"
        db.iniDataset(Sql)
        Me.viewgiahan.DataSource = db.mydataset.Tables(0)
    End Sub
    Private Sub btgiahan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btgiahan.Click
        db.connectDB()
        If Me.cbmabandoc.Text = "" Then
            MsgBox("Chưa chọn Mã Bạn Đọc")
        Else
            sql = "UPDATE BanDoc SET Ngayhethan=N'" + Me.giahan.Value.Date.ToString() + "' where MaBD=N'" + Me.cbmabandoc.Text.ToString + "'"
            db.doSQL(sql)
            Me.showDataGrid()
        End If
    End Sub



End Class